package com.scorekeeper;

import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class LoaderDialog extends DialogFragment {
	public static LoaderDialog newInstance(Bundle args) {
		LoaderDialog f = new LoaderDialog();
		
		f.setArguments(args);
		return f;
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		int style = DialogFragment.STYLE_NO_TITLE, theme = android.R.style.Theme_Holo;
		
		setStyle(style, theme);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.fragment_dialog, container, false);
		View tv = v.findViewById(R.id.textView1);
		((TextView) tv).setText(getArguments().getString("action_text", "Please wait..."));
		
		final Intent intent = new Intent();
		intent.setClassName(this.getActivity(), getArguments().getString("class"));
		intent.putExtra("team", getArguments().getString("team"));
		
		startActivity(intent);
		
		return v;
	}
}